<layout name="popup" />
<block name="content">
	<input type="hidden" name="ajax" id="ajax" value="1">
	<div class="popup-header">
		<h1>添加后台任务</h1>
		<i class="mid"></i>
		<a class="btn btn-normal" onclick="save();">确定</a>
		<a class="btn btn-return" onclick="close_popup();">取消</a>
	</div>
	<div class="popup-body">
		<div class="popup-body-scroll">
			<div class="popup-content">
				<form id="form_data" name="form_data" method="post" >
					<input type="hidden" name="id" id="id" >
					<input type="hidden" name="opmode" id="opmode" value="add">
					<div class="box">
						<label class="input-label" for="name">名称*：</label>
						<input class="input" type="text" id="name" name="name" check="required" info="请输入名称">
					</div>
					<div class="box">
						<label class="input-label" for="command">命令*：</label>
						<input class="input" type="text" id="command" name="command" check="required" info="请输入命令">
					</div>
					<div class="box">
						<label class="input-label">类型*：</label>
						<label class="label w3">每</label>
						<input type="text" class="input w8"  name="interval" id="interval">
						<div class="w1"></div>
						<select class="select w8" name="type" id="type" onchange="test()">
							<option>请选择</option>
							<option value="D">天</option>
							<option value="S">秒</option>
						</select>
						<div class="w1"></div>
						<input class="input hidden w8" type="time" id="time" name="time">
					</div>
					<div class="box">
						<label class="input-label" for="start_date">开始日期*：</label>
						<input class="input input-date" type="text" id="start_date" name="start_date" check="required" info="请选择开始日期">
					</div>
					<div class="box">
						<label class="input-label" for="end_date">结束日期*：</label>
						<input class="input input-date" type="text" id="end_date" name="end_date" check="required" info="">
					</div>
					<div class="box">
						<label class="input-label" for="sort">排序：</label>
						<input class="input w10" type="text" id="sort" name="sort" >
					</div>
				</form>
			</div>
		</div>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		var index = parent.layer.getFrameIndex(window.name);
		layui.use(['global'], function() {
			var fn = {
				save : function() {
					send_form('form_data', '{:url("save_timer")}', '', function(ret) {
						if (ret.status == 1) {
							parent.layer.msg(ret.info, {
								time : 1200
							}, function() {
								parent.layer.close(index);
								parent.location.reload(true);
							});
						} else {
							parent.layer.msg(ret.info);
							return false;
						};
					});
				},
				close_popup : function() {
					parent.layer.close(index);
				},
				select_pid : function() {
					winopen("{:url('select_pid')}", 560, 470);
				},
			};
			win_exp(fn);

			$("#type").on('change', function() {
				if ($("#type").val() == 'D') {
					$("#time").removeClass('hidden');
				} else {
					$("#time").addClass('hidden');
				}
			});
		});

	</script>
</block>